package vista.paneles;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;



import controlador.Controlador;

public class EastPanel extends JPanel {
	
	private JLabel label1;
	private JLabel label2;
	private JSlider speed;
	private SliderListener listener;
	private Controlador controlador;

	public EastPanel(Controlador control) {
		
		setLayout(new BorderLayout());
		controlador = control;
		label1 = new JLabel("    + Velocidad      ");
		label2 = new JLabel("    - Velocidad      ");
		speed = new JSlider(SwingConstants.VERTICAL,0,500,10);
		//speed.setMajorTickSpacing(1);
		speed.setValue(250);
		controlador.setSimulationSpeed(speed.getValue());
		listener = new SliderListener();
		speed.addChangeListener(listener);
		add(BorderLayout.NORTH,label1);
		add(BorderLayout.SOUTH,label2);
		add(BorderLayout.CENTER,speed);
	}
	
	public JSlider getSpeed() {
		return speed;
	}

	public void setSpeed(JSlider speed) {
		this.speed = speed;
	}

	class SliderListener implements ChangeListener {

		public void stateChanged(ChangeEvent e) {
		
			controlador.setSimulationSpeed(speed.getValue());
		}
	}
}
